<?php

// Check to ensure this file is included in Joomla!

defined('_JEXEC') or die();

jimport('joomla.application.component.view');

class StaffViewStaff_edit extends JView {

    function display($tpl = null) {
        global $mainframe;

        $db = & JFactory::getDBO();
        $uri = & JFactory::getURI();
        $model = & $this->getModel();
        $document = & JFactory::getDocument();

        $item = & $this->get('data');
        $isNew = ($item->id < 1);
        if ($isNew) {
            $item->name = 1;
            $item->name = null;
            $item->alias = null;
            $item->published = 1;
            $item->age = 0;
            $item->phone = null;
            $item->img = null;
            $item->address = null;
            $item->email = null;
            $item->position = null;
            $item->field = null;
            $item->rank = null;
            $item->archive = null;
            $item->projects = null;
            $item->education = null;
            $item->technical = null;
            $item->date_validate = null;
            $item->department_id = 0;
            $item->gender = 'Nam';
            $item->yearGS = null;
            $item->yearPGS = null;
            
        }

        // list
        $lists = array();
        $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);

        // danh muc
        $query = 'SELECT c.id AS value, c.name AS text '
                . ' FROM #__ciid_staff_departments AS c'
        ;
        $db->setQuery($query);
        $catList[] = JHTML::_('select.option', '0', JText::_('--- Chọn cơ quan ---'));
        $catList = array_merge($catList, $db->loadObjectList());
        $lists['category'] = JHTML::_('select.genericlist', $catList, 'department_id', 'class="inputbox" ', 'value', 'text', $item->department_id);

        $gender = array();
        $gender[] = JHTML::_('select.option', 'Nam', 'Nam');
        $gender[] = JHTML::_('select.option', 'Nữ', 'Nữ');
        $lists['gender'] = JHTML::_('select.radiolist', $gender, 'gender', 'class="inputbox" ', 'value', 'text', $item->gender);

        $rank = array();
        $rank[] = JHTML::_('select.option', '0', JText::_('--- Chọn học vị ---'));
        $rank[] = JHTML::_('select.option', 'Tiến sĩ Khoa học', 'Tiến sĩ Khoa học');
        $rank[] = JHTML::_('select.option', 'Tiến sĩ', 'Tiến sĩ');
        $rank[] = JHTML::_('select.option', 'Thạc sĩ', 'Thạc sĩ');
        $rank[] = JHTML::_('select.option', 'Đại học', 'Đại học');
        $lists['rank'] = JHTML::_('select.genericlist', $rank, 'rank', 'class="inputbox" ', 'value', 'text', $item->rank);
        
        $this->assignRef('item', $item);
        $this->assignRef('lists', $lists);

        parent::display($tpl);
    }

    function buildList($min, $max, $name, $value) {
        //$option = array();
        for ($i = $min; $i <= $max; $i++) {
            $option[] = JHTML::_('select.option', $i, $i);
        }
        $list = JHTML::_('select.genericlist', $option, $name, 'class="inputbox" ', 'value', 'text', $value);
        return $list;
    }

}

?>